/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package cosc617_blackteam;

import java.util.ArrayList;
//import java.util.HashMap;
//import java.util.Map;

/**
 *
 * @author Anton
 */
public class Invoker {

    private ArrayList<I_Command> commandsHistory = new ArrayList<>();// not sure we actually need this but just in case
    // private Map<CommandName, I_Command> commands = new HashMap<>();

    public Invoker() {

    }

    /**
     * @param commandKey the key that maps to the relevant command.
     * @return the objected returned by the command executed from the commands
     * Map
     *//*
     public Object request(CommandName commandKey) {
     if (this.commands.containsKey(commandKey)) {
     return this.commands.get(commandKey).execute();
     }
     return null;//NullCommandObject().execute(); - no reason to use a null object if we just return null. 
     }*/

    /**
     * This would be if we are adhering to a more command-pattern like design
     * where the invokers only role is to execute the commands and possibly
     * store them in a history.
     *
     * @param command - The command to be executed
     * @return the object returned by the command
     */
    public Object execute(I_Command command) {
        this.commandsHistory.add(command);
        return command.execute();
    }
    /**
     * @param commandKey the key that will be used for the commandObject. Key
     * names are of enum type CommandName and thus do not need formatting
     * @param commandObject the new instantiation of a command.
     *//*
     public final void addCommand(CommandName commandKey, I_Command commandObject) {
     this.commands.put(commandKey, commandObject);
     }*/

}
